package com.topscore.uke.mvp.presenters;

import com.topscore.uke.entities.StaffInfoEntity;
import com.topscore.uke.mvp.contractors.UpdateUserInfoContractor;
import com.topscore.uke.mvp.model.GetUserInfoModel;
import com.topscore.uke.network.BaseResponse;
import com.topscore.uke.utils.UserInfoManager;

public class UpdateUserInfoPresenter implements UpdateUserInfoContractor,UpdateUserInfoContractor.Presenter {
    private Model mModel;
    private View mView;

    public UpdateUserInfoPresenter(View view) {
        this.mView = view;
        mModel = new GetUserInfoModel(new Model.CallBack() {
            @Override
            public void onSuccess(BaseResponse<StaffInfoEntity> response) {
                mView.onGetDataSuccess(response.getData());
            }

            @Override
            public void onError(int errorCode, String errorMessage) {
                mView.onFail(errorCode,errorMessage);
            }

            @Override
            public void onComplete() {
                mView.onLoadFinished();
            }
        });
    }

    @Override
    public void updateUserInfo() {
        String loginName = UserInfoManager.getUserInfo().getLoginName();
        String role = UserInfoManager.getUserInfo().getRole();
        mModel.getUserData(loginName,role);
    }
}
